<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>
<body>

<!--
    在子组件中接收到的父组件中的参数不要直接改变参数的值  如何需要操作接收的参数  可以先将
    接收的数值赋值给另外一个属性

    [Vue warn]: Avoid mutating a prop directly since the value will be overwritten
    whenever the parent component re-renders.
    Instead, use a data or computed property based on the prop's value.
    Prop being mutated: "num
-->
<div id="app">
    <blog :num=num></blog>
</div>

<script>
    // 博客组件
    let blog = {
        template: `
          <div>
            {{ count }}
            <button @click="add">+1</button>
          </div>
        `,
        data() {
            return {
                count: this.num
            }
        },
        methods: {
            add() {
                this.count++
            }
        },
        props: ['num']
    }
    let vm = new Vue({
        el: '#app',
        data: {
            num: 10
        },
        components: {
            blog
        }
    })
</script>
</body>
</html>